//
//  SRCommentViewController.m
//  SportRing
//
//  Created by icelee on 14-11-1.
//  Copyright (c) 2014年 HotOne. All rights reserved.
//

#import "SRCommentViewController.h"
#import "SRCommentView.h"
#import "SRSystemNetService.h"

@interface SRCommentViewController ()<UITextViewDelegate>

@property (nonatomic, weak)IBOutlet SRCommentView *srCommentView;
@property (weak, nonatomic) IBOutlet UITextView *tuCao;

@end

@implementation SRCommentViewController

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:SVProgressHUDDidDisappearNotification object:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addBackButton];
    [self setCustomTitle:NSLocalizedString(@"我要吐槽", nil)];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(SVProgressHudDidDissmiss:) name:SVProgressHUDDidDisappearNotification object:nil];
    _tuCao.delegate = self;
    // Do any additional setup after loading the view.
}

- (void)textViewDidBeginEditing:(UITextView *)textView {
    
    textView.text = @"";
    textView.textColor = [UIColor darkGrayColor];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self hideTabbar];
    self.navigationController.navigationBarHidden = NO;

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - SRCommentViewDelegate
- (void)commitComment:(NSString *)comment
{
    [SVProgressHUD show];
    
    [[SRSystemNetService careCommonWithThink:comment] subscribeNext:^(id x) {
        
        [SVProgressHUD showSuccessWithStatus:@"您的反馈我们已经收到，谢谢！"];
        
    } error:^(NSError *error) {
        
        [SVProgressHUD showErrorWithStatus:@"很遗憾，您的反馈,提交失败..."];

    }];

}

#pragma mark - SVProgressHUDDidDisappearNotification

- (void)SVProgressHudDidDissmiss:(NSNotification *)notification
{
    [self.navigationController popViewControllerAnimated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
